package vs_a1;

import java.util.ArrayList;
import java.util.Date;
/**
 * ClientType:
 * stores all information about a client.
 *  -> last access
 *  -> ID of the client
 *  -> a list of all retrieved messages
 * @author Jan Quenzel
 * @author Rico Flaegel
 */
public class ClientType {
	long t;
	String clientID;
	ArrayList<Long> al;
	/**
	 * Constructor
	 * @param cID ID of the client
	 */
	public ClientType(String cID){
		al = new ArrayList<Long>();
		clientID = cID;
		setActualTime();
	}
	/**
	 * Standard Constructor
	 */
	public ClientType(){
		this("");
	}
	/**
	 * Adds a Message to the list of send messages to the server.
	 * refreshes the last action timestamp.
	 * @param m ID of a message
	 */
	public void add(long m) {
		al.add(m);
		setActualTime();
	}
	/**
	 * Refresh the timestamp.
	 */
	public void setActualTime(){
		t = new Date().getTime();
	}
	
	public Date getTime(){
		return new Date(t);
	}
	/**
	 * Has the client received a message with given ID?
	 * @param messageID the ID of the message in question
	 * @return true if contained, else false.
	 */
	public boolean contains(long messageID) {
		return al.contains(messageID);
	}
	
}
